const Router = require('koa-router')
const router = new Router()
router.prefix('/api/book')

const { //控制器
  find, findById, create, update, delete: del,
  checkOptionExist,bookUpload,bookList
} = require('../controllers/book')

const { //中间件
  auth, checkUserAuthorization
} = require('../middleware/index')

router.get('/backgroundImage', find) //获取书籍背景图选项列表

router.get('/backgroundImage/:id', checkOptionExist, findById) //获取指定详情

router.post('/backgroundImage', auth, checkUserAuthorization, create) //书籍背景图添加

router.patch('/backgroundImage/:id', auth, checkUserAuthorization, checkOptionExist, update) //更新

router.delete('/backgroundImage/:id', auth, checkUserAuthorization, checkOptionExist, del) //删除

router.get('/bookList', bookList) //获取书籍文件列表

router.post('/addBook', auth, bookUpload) // 上传书籍文件

module.exports = router
